import { ajaxService } from '@/utils/request';
import {
  GetsingleDepartment,
  addDepartment,
  delDepartment,
  modDepartment,
} from '../../type';

const env = import.meta.env;
let baseURL = env.VITE_STAFF_URL;
// let baseURL = 'http://192.168.0.120:19001';

// 获取所有部门
export function Getdepartment() {
  return ajaxService({
    url: '/staff/department/getAll',
    method: 'get',
    baseURL,
  });
}

// 获取单个部门信息
export function Getsingledepartment(params: GetsingleDepartment) {
  return ajaxService({
    url: '/staff/department/get',
    params,
    method: 'get',
    baseURL,
  });
}

// 添加部门
export function addDepartment(data: addDepartment) {
  return ajaxService({
    url: '/staff/department/add',
    data,
    method: 'post',
    baseURL,
  });
}

// 删除部门
export function delDepartment(params: delDepartment) {
  return ajaxService({
    url: '/staff/department/del',
    params,
    method: 'delete',
    baseURL,
  });
}

// 修改部门
export function modDepartment(data: modDepartment) {
  return ajaxService({
    url: '/staff/department/mod',
    data,
    method: 'put',
  });
}
